val param = btnClickMe.layoutParams as ViewGroup.MarginLayoutParams param.setMargins(10,10,10,10) btnClickMe.layoutParams = param // Tested!! - You need this line for the params to be applied.